Skip to contentSkip to conversation

Change in openvpn[master]: push_util: Fix conversion warnings

Openvpn-devel In review flichtenheld (Code Review) 2 participants 7 messages Oct 17, 2025 – Oct 18, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1760698129000.I4113d14c6ce33818573b0ca5857a9ab39b35a8f4@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email

to review the following change.

Change subject: push_util: Fix conversion warnings
......................................................................

push_util: Fix conversion warnings

Mostly just use better types.

Change-Id I4113d14c6ce33818573b0ca5857a9ab39b35a8f4

---
M src/openvpn/push_util.c

1 file changed, 15 insertions(+), 24 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/1283/1

src/openvpn/push_util.c +15 -24
index 06b4c8b..8c1a503 100644
@@ -10,18 +10,13 @@
 #include "ssl_util.h"
 #endif
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 process_incoming_push_update(struct context *c, unsigned int permission_mask,
                              unsigned int *option_types_found, struct buffer *buf,
                              bool msg_sender)
 {
     int ret = PUSH_MSG_ERROR;
-    const uint8_t ch = buf_read_u8(buf);
+    const int ch = buf_read_u8(buf);
     if (ch == ',')
     {
         if (apply_push_options(c, &c->options, buf, permission_mask, option_types_found, c->c2.es,
@@ -57,8 +52,8 @@
  * Return index of last `,` or `0` if it didn't find any.
  * If there is a comma at index `0` it's an error anyway
  */
-static int
-find_first_comma_of_next_bundle(const char *str, int ix)
+static size_t
+find_first_comma_of_next_bundle(const char *str, size_t ix)
 {
     while (ix > 0)
     {
@@ -75,8 +70,8 @@
 static struct buffer
 forge_msg(const char *src, const char *continuation, struct gc_arena *gc)
 {
-    int src_len = strlen(src);
-    int con_len = continuation ? strlen(continuation) : 0;
+    size_t src_len = strlen(src);
+    size_t con_len = continuation ? strlen(continuation) : 0;
     struct buffer buf = alloc_buf_gc(src_len + sizeof(push_update_cmd) + con_len + 2, gc);
 
     buf_printf(&buf, "%s,%s%s", push_update_cmd, src, continuation ? continuation : "");
@@ -93,11 +88,11 @@
     return ret;
 }
 
-/* It split the messagge (if necessay) and fill msgs with the message chunks.
+/* It split the messagge (if necessary) and fill msgs with the message chunks.
  * Return `false` on failure an `true` on success.
  */
 static bool
-message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const int safe_cap)
+message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const size_t safe_cap)
 {
     if (!s || !*s)
     {
@@ -105,7 +100,7 @@
     }
 
     char *str = gc_strdup(s, gc);
-    int i = 0;
+    size_t i = 0;
     int im = 0;
 
     while (*str)
@@ -113,7 +108,7 @@
         /* + ',' - '/0' */
         if (strlen(str) > safe_cap)
         {
-            int ci = find_first_comma_of_next_bundle(str, safe_cap);
+            size_t ci = find_first_comma_of_next_bundle(str, safe_cap);
             if (!ci)
             {
                 /* if no commas were found go to fail, do not send any message */
@@ -219,7 +214,7 @@
  * @return The number of clients to which the message was sent. Might return < 0 in case of error.
  */
 static int
-send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const int push_bundle_size)
+send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const size_t push_bundle_size)
 {
     if (dco_enabled(&m->top.options))
     {
@@ -228,19 +223,19 @@
         return 0;
     }
 
-    if (!msg || !*msg || !m
-        || (!target && type != UPT_BROADCAST))
+    if (!msg || !*msg || !m || (!target && type != UPT_BROADCAST))
     {
         return -EINVAL;
     }
 
     struct gc_arena gc = gc_new();
     /* extra space for possible trailing ifconfig and push-continuation */
-    const int extra = 84 + sizeof(push_update_cmd);
+    const size_t extra = 84 + sizeof(push_update_cmd);
     /* push_bundle_size is the maximum size of a message, so if the message
      * we want to send exceeds that size we have to split it into smaller messages */
-    const int safe_cap = push_bundle_size - extra;
-    int msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
+    ASSERT(push_bundle_size > extra);
+    const size_t safe_cap = push_bundle_size - extra;
+    size_t msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
     struct buffer *msgs = gc_malloc((msgs_num + 1) * sizeof(struct buffer), true, &gc);
 
     unsigned int option_types_found = 0;
@@ -354,7 +349,3 @@
     RETURN_UPDATE_STATUS(n_sent);
 }
 #endif /* ifdef ENABLE_MANAGEMENT */
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4
Gerrit-Change-Number: 1283
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, mrbff, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email )

Change subject: push_util: Fix conversion warnings
......................................................................

Patch Set 1: Code-Review+1

(1 comment)

Patchset:

PS1:
It looks generally good to me, but I would be happy if @[email protected]... could run a few tests with message splitting - I'm a bit too tired to verify the math there (push_bundle_size)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4
Gerrit-Change-Number: 1283
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: mrbff <[email protected]...>
Gerrit-Comment-Date: Fri, 17 Oct 2025 20:43:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, flichtenheld, plaisthos.

mrbff has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email )

Change subject: push_util: Fix conversion warnings
......................................................................

Patch Set 1: Code-Review+2

(1 comment)

Patchset:

PS1:

Quoted 1 line

It looks generally good to me, but I would be happy if @[email protected]... […]

LGTM

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4
Gerrit-Change-Number: 1283
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 17 Oct 2025 21:51:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: cron2 <[email protected]...>

#4 lore raw

PATCH 1/1 push_util: Fix conversion warnings

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

Mostly just use better types.

Change-Id I4113d14c6ce33818573b0ca5857a9ab39b35a8f4

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
mrbff <[email protected]...>

src/openvpn/push_util.c +15 -24
index 06b4c8b..8c1a503 100644
@@ -10,18 +10,13 @@
 #include "ssl_util.h"
 #endif
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 process_incoming_push_update(struct context *c, unsigned int permission_mask,
                              unsigned int *option_types_found, struct buffer *buf,
                              bool msg_sender)
 {
     int ret = PUSH_MSG_ERROR;
-    const uint8_t ch = buf_read_u8(buf);
+    const int ch = buf_read_u8(buf);
     if (ch == ',')
     {
         if (apply_push_options(c, &c->options, buf, permission_mask, option_types_found, c->c2.es,
@@ -57,8 +52,8 @@
  * Return index of last `,` or `0` if it didn't find any.
  * If there is a comma at index `0` it's an error anyway
  */
-static int
-find_first_comma_of_next_bundle(const char *str, int ix)
+static size_t
+find_first_comma_of_next_bundle(const char *str, size_t ix)
 {
     while (ix > 0)
     {
@@ -75,8 +70,8 @@
 static struct buffer
 forge_msg(const char *src, const char *continuation, struct gc_arena *gc)
 {
-    int src_len = strlen(src);
-    int con_len = continuation ? strlen(continuation) : 0;
+    size_t src_len = strlen(src);
+    size_t con_len = continuation ? strlen(continuation) : 0;
     struct buffer buf = alloc_buf_gc(src_len + sizeof(push_update_cmd) + con_len + 2, gc);
 
     buf_printf(&buf, "%s,%s%s", push_update_cmd, src, continuation ? continuation : "");
@@ -93,11 +88,11 @@
     return ret;
 }
 
-/* It split the messagge (if necessay) and fill msgs with the message chunks.
+/* It split the messagge (if necessary) and fill msgs with the message chunks.
  * Return `false` on failure an `true` on success.
  */
 static bool
-message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const int safe_cap)
+message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const size_t safe_cap)
 {
     if (!s || !*s)
     {
@@ -105,7 +100,7 @@
     }
 
     char *str = gc_strdup(s, gc);
-    int i = 0;
+    size_t i = 0;
     int im = 0;
 
     while (*str)
@@ -113,7 +108,7 @@
         /* + ',' - '/0' */
         if (strlen(str) > safe_cap)
         {
-            int ci = find_first_comma_of_next_bundle(str, safe_cap);
+            size_t ci = find_first_comma_of_next_bundle(str, safe_cap);
             if (!ci)
             {
                 /* if no commas were found go to fail, do not send any message */
@@ -219,7 +214,7 @@
  * @return The number of clients to which the message was sent. Might return < 0 in case of error.
  */
 static int
-send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const int push_bundle_size)
+send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const size_t push_bundle_size)
 {
     if (dco_enabled(&m->top.options))
     {
@@ -228,19 +223,19 @@
         return 0;
     }
 
-    if (!msg || !*msg || !m
-        || (!target && type != UPT_BROADCAST))
+    if (!msg || !*msg || !m || (!target && type != UPT_BROADCAST))
     {
         return -EINVAL;
     }
 
     struct gc_arena gc = gc_new();
     /* extra space for possible trailing ifconfig and push-continuation */
-    const int extra = 84 + sizeof(push_update_cmd);
+    const size_t extra = 84 + sizeof(push_update_cmd);
     /* push_bundle_size is the maximum size of a message, so if the message
      * we want to send exceeds that size we have to split it into smaller messages */
-    const int safe_cap = push_bundle_size - extra;
-    int msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
+    ASSERT(push_bundle_size > extra);
+    const size_t safe_cap = push_bundle_size - extra;
+    size_t msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
     struct buffer *msgs = gc_malloc((msgs_num + 1) * sizeof(struct buffer), true, &gc);
 
     unsigned int option_types_found = 0;
@@ -354,7 +349,3 @@
     RETURN_UPDATE_STATUS(n_sent);
 }
 #endif /* ifdef ENABLE_MANAGEMENT */
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
#5 lore raw

[Openvpn-devel] [PATCH applied] Re: push_util: Fix conversion warnings

Smoke tested ("does it compile and pass client side tests"). Still no real testbed for PUSH_UPDATE, alas. Marco says it's fine, and it's his code, and BB agrees, forward we move ;-)

Application of the patch needed a bit of pressure because quite a bit of context has changed in the meantime (commit 5e4c9a69eaf) - but only context, no affected code itself.

Your patch has been applied to the master branch.

commit a8b8e41c7906c895ba6c88aa748e6dfa3946aff5

Author: Frank Lichtenheld
Date:   Sat Oct 18 19:02:32 2025 +0200
     push_util: Fix conversion warnings

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: mrbff <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283
     Message-Id: <[email protected]...>
     URL: https://sourceforge.net/p/openvpn/mailman/message/59248341/
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2.

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email )

The following approvals got outdated and were removed:
Code-Review+1 by cron2, Code-Review+2 by mrbff

Change subject: push_util: Fix conversion warnings
......................................................................

push_util: Fix conversion warnings

Mostly just use better types.

Change-Id I4113d14c6ce33818573b0ca5857a9ab39b35a8f4

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59248341/

---
M src/openvpn/push_util.c

1 file changed, 15 insertions(+), 24 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/83/1283/2

src/openvpn/push_util.c +15 -24
index 0eddcae..552679a 100644
@@ -10,17 +10,12 @@
 #include "ssl_util.h"
 #endif
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 process_push_update(struct context *c, struct options *o, unsigned int permission_mask,
                     unsigned int *option_types_found, struct buffer *buf, bool msg_sender)
 {
     int ret = PUSH_MSG_ERROR;
-    const uint8_t ch = buf_read_u8(buf);
+    const int ch = buf_read_u8(buf);
     if (ch == ',')
     {
         if (apply_push_options(c, o, buf, permission_mask, option_types_found, c->c2.es,
@@ -56,8 +51,8 @@
  * Return index of last `,` or `0` if it didn't find any.
  * If there is a comma at index `0` it's an error anyway
  */
-static int
-find_first_comma_of_next_bundle(const char *str, int ix)
+static size_t
+find_first_comma_of_next_bundle(const char *str, size_t ix)
 {
     while (ix > 0)
     {
@@ -74,8 +69,8 @@
 static struct buffer
 forge_msg(const char *src, const char *continuation, struct gc_arena *gc)
 {
-    int src_len = strlen(src);
-    int con_len = continuation ? strlen(continuation) : 0;
+    size_t src_len = strlen(src);
+    size_t con_len = continuation ? strlen(continuation) : 0;
     struct buffer buf = alloc_buf_gc(src_len + sizeof(push_update_cmd) + con_len + 2, gc);
 
     buf_printf(&buf, "%s,%s%s", push_update_cmd, src, continuation ? continuation : "");
@@ -92,11 +87,11 @@
     return ret;
 }
 
-/* It split the messagge (if necessay) and fill msgs with the message chunks.
+/* It split the messagge (if necessary) and fill msgs with the message chunks.
  * Return `false` on failure an `true` on success.
  */
 static bool
-message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const int safe_cap)
+message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const size_t safe_cap)
 {
     if (!s || !*s)
     {
@@ -104,7 +99,7 @@
     }
 
     char *str = gc_strdup(s, gc);
-    int i = 0;
+    size_t i = 0;
     int im = 0;
 
     while (*str)
@@ -112,7 +107,7 @@
         /* + ',' - '/0' */
         if (strlen(str) > safe_cap)
         {
-            int ci = find_first_comma_of_next_bundle(str, safe_cap);
+            size_t ci = find_first_comma_of_next_bundle(str, safe_cap);
             if (!ci)
             {
                 /* if no commas were found go to fail, do not send any message */
@@ -254,7 +249,7 @@
  * @return The number of clients to which the message was sent. Might return < 0 in case of error.
  */
 static int
-send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const int push_bundle_size)
+send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const size_t push_bundle_size)
 {
     if (dco_enabled(&m->top.options))
     {
@@ -263,19 +258,19 @@
         return 0;
     }
 
-    if (!msg || !*msg || !m
-        || (!target && type != UPT_BROADCAST))
+    if (!msg || !*msg || !m || (!target && type != UPT_BROADCAST))
     {
         return -EINVAL;
     }
 
     struct gc_arena gc = gc_new();
     /* extra space for possible trailing ifconfig and push-continuation */
-    const int extra = 84 + sizeof(push_update_cmd);
+    const size_t extra = 84 + sizeof(push_update_cmd);
     /* push_bundle_size is the maximum size of a message, so if the message
      * we want to send exceeds that size we have to split it into smaller messages */
-    const int safe_cap = push_bundle_size - extra;
-    int msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
+    ASSERT(push_bundle_size > extra);
+    const size_t safe_cap = push_bundle_size - extra;
+    size_t msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
     struct buffer *msgs = gc_malloc((msgs_num + 1) * sizeof(struct buffer), true, &gc);
 
     msgs[msgs_num].data = NULL;
@@ -374,7 +369,3 @@
     RETURN_UPDATE_STATUS(n_sent);
 }
 #endif /* ifdef ENABLE_MANAGEMENT */
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4
Gerrit-Change-Number: 1283
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2.

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email )

Change subject: push_util: Fix conversion warnings
......................................................................

push_util: Fix conversion warnings

Mostly just use better types.

Change-Id I4113d14c6ce33818573b0ca5857a9ab39b35a8f4

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1283
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59248341/

---
M src/openvpn/push_util.c

1 file changed, 15 insertions(+), 24 deletions(-)
src/openvpn/push_util.c +15 -24
index 0eddcae..552679a 100644
@@ -10,17 +10,12 @@
 #include "ssl_util.h"
 #endif
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 int
 process_push_update(struct context *c, struct options *o, unsigned int permission_mask,
                     unsigned int *option_types_found, struct buffer *buf, bool msg_sender)
 {
     int ret = PUSH_MSG_ERROR;
-    const uint8_t ch = buf_read_u8(buf);
+    const int ch = buf_read_u8(buf);
     if (ch == ',')
     {
         if (apply_push_options(c, o, buf, permission_mask, option_types_found, c->c2.es,
@@ -56,8 +51,8 @@
  * Return index of last `,` or `0` if it didn't find any.
  * If there is a comma at index `0` it's an error anyway
  */
-static int
-find_first_comma_of_next_bundle(const char *str, int ix)
+static size_t
+find_first_comma_of_next_bundle(const char *str, size_t ix)
 {
     while (ix > 0)
     {
@@ -74,8 +69,8 @@
 static struct buffer
 forge_msg(const char *src, const char *continuation, struct gc_arena *gc)
 {
-    int src_len = strlen(src);
-    int con_len = continuation ? strlen(continuation) : 0;
+    size_t src_len = strlen(src);
+    size_t con_len = continuation ? strlen(continuation) : 0;
     struct buffer buf = alloc_buf_gc(src_len + sizeof(push_update_cmd) + con_len + 2, gc);
 
     buf_printf(&buf, "%s,%s%s", push_update_cmd, src, continuation ? continuation : "");
@@ -92,11 +87,11 @@
     return ret;
 }
 
-/* It split the messagge (if necessay) and fill msgs with the message chunks.
+/* It split the messagge (if necessary) and fill msgs with the message chunks.
  * Return `false` on failure an `true` on success.
  */
 static bool
-message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const int safe_cap)
+message_splitter(const char *s, struct buffer *msgs, struct gc_arena *gc, const size_t safe_cap)
 {
     if (!s || !*s)
     {
@@ -104,7 +99,7 @@
     }
 
     char *str = gc_strdup(s, gc);
-    int i = 0;
+    size_t i = 0;
     int im = 0;
 
     while (*str)
@@ -112,7 +107,7 @@
         /* + ',' - '/0' */
         if (strlen(str) > safe_cap)
         {
-            int ci = find_first_comma_of_next_bundle(str, safe_cap);
+            size_t ci = find_first_comma_of_next_bundle(str, safe_cap);
             if (!ci)
             {
                 /* if no commas were found go to fail, do not send any message */
@@ -254,7 +249,7 @@
  * @return The number of clients to which the message was sent. Might return < 0 in case of error.
  */
 static int
-send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const int push_bundle_size)
+send_push_update(struct multi_context *m, const void *target, const char *msg, const push_update_type type, const size_t push_bundle_size)
 {
     if (dco_enabled(&m->top.options))
     {
@@ -263,19 +258,19 @@
         return 0;
     }
 
-    if (!msg || !*msg || !m
-        || (!target && type != UPT_BROADCAST))
+    if (!msg || !*msg || !m || (!target && type != UPT_BROADCAST))
     {
         return -EINVAL;
     }
 
     struct gc_arena gc = gc_new();
     /* extra space for possible trailing ifconfig and push-continuation */
-    const int extra = 84 + sizeof(push_update_cmd);
+    const size_t extra = 84 + sizeof(push_update_cmd);
     /* push_bundle_size is the maximum size of a message, so if the message
      * we want to send exceeds that size we have to split it into smaller messages */
-    const int safe_cap = push_bundle_size - extra;
-    int msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
+    ASSERT(push_bundle_size > extra);
+    const size_t safe_cap = push_bundle_size - extra;
+    size_t msgs_num = (strlen(msg) / safe_cap) + ((strlen(msg) % safe_cap) != 0);
     struct buffer *msgs = gc_malloc((msgs_num + 1) * sizeof(struct buffer), true, &gc);
 
     msgs[msgs_num].data = NULL;
@@ -374,7 +369,3 @@
     RETURN_UPDATE_STATUS(n_sent);
 }
 #endif /* ifdef ENABLE_MANAGEMENT */
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1283?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4113d14c6ce33818573b0ca5857a9ab39b35a8f4
Gerrit-Change-Number: 1283
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: mrbff <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: cron2 <[email protected]...>